Skip to content

Integrate SonarQube Cloud workflow Analysis#689

Merged
mpusz merged 2 commits intompusz:masterfrom
alejandro-alvarez-sonarsource:aa/sonarcloud
Dec 21, 2025
Merged

Integrate SonarQube Cloud workflow Analysis#689
mpusz merged 2 commits intompusz:masterfrom
alejandro-alvarez-sonarsource:aa/sonarcloud

Conversation

@alejandro-alvarez-sonarsource
Copy link
Copy Markdown
Contributor

Hello,

As we discussed, here is the workflow file adding the CI for analyzing the code in SonarQube Cloud.
Here is an example of a successful run. We can see this in the logs:

06:33:03.769 INFO  0 compilation units were partially analyzed
06:33:03.778 INFO  Analysis measures statistics:
100% of classes were parsed successfully (0 out of 1163 have parsing errors)
100% of functions were parsed successfully (0 out of 1036 have parsing errors)
100% of statements were parsed successfully (0 out of 9318 have parsing errors)
100% of the project includes directives were resolved (0 out of 1108 were not resolved)

Which means there was nothing that we had trouble parsing, and hence the results are complete.

And here you can see the results of the analysis.

I am not sure about the reliability of coverage, though. I can see some consteval being flagged as not being executed during runtime, which of course they aren't. Since coverage is handled by clang for instrumentation and llvm-cov for extracting the information, I imagine it's more on their side.

If you are happy with this, you will need two new secrets: SONAR_TOKEN and SONAR_HOST_URL (the latter just being https://sonarcloud.io, not really a secret). For the token you will need to onboard the project, then go to Administration / Analysis Method, disable automatic analysis and follow the instructions for GitHub Actions.

If you need help setting anything up, I'll happy to help.

P.S I think it may be better to merge into a temporary branch that lives under your repo to make sure it works, since I believe actions with secrets do not run when the PR comes from the outside.

P.P.S Full disclosure, I have seen a handful of kind-of-false positives for "Identical sub-expressions on both sides of operator" (they are identical, but they are within requires, and it should not apply there IMHO). I have filed a ticket for these.
Rules you disagree with can be disabled, though.

Copy link
Copy Markdown
Owner

@mpusz mpusz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took much longer than I thought. Thank you again for your help! 👍

@mpusz mpusz merged commit 83236e4 into mpusz:master Dec 21, 2025
81 checks passed
@mpusz
Copy link
Copy Markdown
Owner

mpusz commented Apr 1, 2026

Hi @alejandro-alvarez-sonarsource!

Can you check out: https://github.com/mpusz/mp-units/actions/runs/23859267371/job/69561133842? Can we fix that somehow? I would like for this workflow to reurn meaningful results and not just fail all the time :-(

@alejandro-alvarez-sonarsource
Copy link
Copy Markdown
Contributor Author

Hi @alejandro-alvarez-sonarsource!

Can you check out: https://github.com/mpusz/mp-units/actions/runs/23859267371/job/69561133842? Can we fix that somehow? I would like for this workflow to reurn meaningful results and not just fail all the time :-(

Hi,

I’ve only managed to reproduce this locally and not deterministically. So far it has only happened when I jump between commits while keeping the existing build directory.

My current suspicion is ccache: it doesn’t support C++20 modules properly (see ccache/ccache#1252) and may be restoring stale artifacts (.o and/or .gcno) from the cache. Since ccache keys based on flags/compiler + preprocessed sources, it may not notice that an imported module changed, so a cached object/.gcno can look “valid” to ccache but be inconsistent for gcovr.

On GitHub runners I haven’t seen it happening at all, and my ccache there is empty, which seems to point in the same direction.

I’d suggest we disable ccache for this coverage job and see if the issue disappears.

@mpusz
Copy link
Copy Markdown
Owner

mpusz commented Apr 2, 2026

Sure, let's try it

@mpusz
Copy link
Copy Markdown
Owner

mpusz commented Apr 4, 2026

@alejandro-alvarez-sonarsource I think it helped 🤓 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants